/*object 3d
*/ 
#ifndef OBJ3D_H
#define OBJ3D_H

#ifndef uint32
#define uint32 unsigned long
#endif

#define SCREENSHOTMAKER

#define CROSS(dest,V1,V2)                 \
              (dest).x=(V1).y*(V2).z-(V1).z*(V2).y; \
              (dest).y=(V1).z*(V2).x-(V1).x*(V2).z; \
              (dest).z=(V1).x*(V2).y-(V1).y*(V2).x;

#define SUB(dest,V1,V2)                 \
              (dest).x=(V1).x-(V2).x; \
              (dest).y=(V1).y-(V2).y; \
              (dest).z=(V1).z-(V2).z;

#define ADD(dest,V1,V2)                 \
              (dest).x=(V1).x+(V2).x; \
              (dest).y=(V1).y+(V2).y; \
              (dest).z=(V1).z+(V2).z;

#define ADDE(dest,V1)                 \
              (dest).x+=(V1).x; \
              (dest).y+=(V1).y; \
              (dest).z+=(V1).z;

#define ADDV(dest,V1,V2,V3)                 \
              (dest).x+=V1; \
              (dest).y+=V2; \
              (dest).z+=V3;

#define SCALE(dest,s,V1)                 \
              (dest).x=s*(V1).x; \
              (dest).y=s*(V1).y; \
              (dest).z=s*(V1).z;


#define DOT(V1,V2)   ((V1).x * (V2).x + (V1).y * (V2).y + (V1).z * (V2).z)

#define MAG(V1)   sqrtf((V1).x*(V1).x + (V1).y*(V1).y + (V1).z*(V1).z)

#define SETVEC(dest,X,Y,Z)   \
              (dest).x=X; \
              (dest).y=Y; \
              (dest).z=Z;


//#define FLOAT0CLIP(amt) ((amt<0.00001f && amt>-0.00001f) ? 0 : amt)
#define FLOAT0CLIP(amt) amt


typedef struct {
	float x;
	float y;
	float z;
} vector;

typedef struct {
	float x,y,z,w;
} quat;

typedef struct {
	unsigned short x,y,z;
} point;

typedef struct {
	unsigned short u,v;
} texcoord;

typedef struct 
{
    float  x,y,z;
    float  nx,ny,nz;
	float  tu,tv;
} vertex;

typedef struct 
{
    unsigned short a,b,c; //points
    unsigned short tv1,tv2,tv3; //texture coords
    unsigned short na,nb,nc; //normals
} triangle;

typedef struct  {
	vector position , target;
	float  roll;
} camera;

typedef struct {
	vector position;
} point_light;

#endif
